﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>用户登录</title>
    <script src="js/axios.min.js"></script>
    <script src="js/vue.min.js"></script>
<link href="css/blog_login.css" rel="stylesheet" type="text/css" media="all"> 
</head>

<body>
<div id="head">
</div>


<div id="body">
<div class="top1">
<ul>
<li>登 陆</li>
</ul>
<hr class="hr1"/>
</div>
<!--<div class="valueDate">
<p>&nbsp;&nbsp;验证码必须填写</p>
<p>&nbsp;&nbsp;用户名必须填写</p>
<p>&nbsp;&nbsp;密码必须填写</p>
</div>-->
<div class="login">
<h1>注册</h1>
<div class="content" id="register">
<p><span>用户名</span> *<br /><input name="username" type="text" class="t_input" v-model="username" size="50" @blur="checkRegister()"/></p>
<p><span>真实姓名</span> *<br /><input name="nickname" type="text" class="t_input" v-model="nickname" size="50"/></p>
<p><span>密码</span> *<br /><input name="password" type="password" class="t_input" v-model="password" size="50"/></p>
<!--<p><span>验证码</span> * <img src="#" /><br /><input name="" type="text" class="t_input" size="50"/></p>
<p><input name="" type="checkbox" value="" />让系统记住我</p>-->
<p><input name="" type="button" value="注 册" @click="userRegister()"/>  <a href="blog_login.html">我要登录</a></p>
<p></p>
</div>
</div>
</div>

<div id="foot">
<hr />
<center>Copyright &copy; 2013-2020</center>
</div>
<script language="JavaScript">
    var vm = new Vue({
        el:"#register",
        data:{
            username:'',
            nickname:'',
            password:''
        },
        methods:{
            userRegister:function () {
                if (vm.username==''){
                    alert("不能为空");
                    return;
                }
                var path="/register";
                var param={username:vm.username,
                    nickname:vm.nickname,
                    password:vm.password};
                //发送ajax请求
                axios.post(path,param).then(function (obj) {
                    if (obj.status==200){
                        var result=obj.data;
                        alert(result.msg);
                        location.href="/blog_login.html";
                    }
                }).catch(function () {
                    alert("注册失败")
                });
            },
            checkRegister:function () {
                if (vm.username==''){
                    alert("不能为空");
                    return;
                }
                var path="/findUserId";
                var param={username:vm.username};
                //发送ajax请求
                axios.get(path,{params:param}).then(function (obj) {
                    if (obj.status==200){
                        var result=obj.data;
                        alert(result.msg);
                    }
                }).catch(function () {
                    alert("注册失败")
                });
            }
        }
    });
</script>
</body>
</html>
